Repository navigation
fix(skills): use the 1.2 client's obstacle ray for skill line of sight - #49
Merged
NickMesser merged 3 commits intoOct 27, 2026
Merged
Conversation
The cast obstacle check still used the C# ray: +1 m at both ends, static+terrain (0x101) and the default 0x8F flags, with no radius gate. The 1.2 client (x2game.dll.c:149877 FUN_390B5540) casts RayWorldIntersection(Game) at unit position height with objtypes 7 (0x107 with check_terrain), flags 0x2048F and one hit; x2game.dll.c:149951 FUN_390B5650 shortens the end point by the target radius and casts no ray when dist <= radius. Unit targets (FUN_390B5C60 -> FUN_3989C0D0) skip the source and target colliders; position targets (FUN_390B5A30 -> FUN_390B5790) use radius 0.5 (DAT_3999C47C) and skip only the source. raycast_ignoring_objects now resolves living proxies, which are stored outside objects, so the unit colliders are actually skipped. The flow tests cover the height/mask/class rule, the radius gate, the 0.5 m position radius and the terrain gate.
The obstacle ray skips the caster and target colliders. Living proxies live outside objects, so the ignore list must resolve ObjKind::Unit through WorldState::living; this test hits the proxy without the skip and passes through it with the skip, and fails if the lookup only reads objects.
The obstacle warn resolved the caster through with_base_unit, whose name is empty for player characters; prefer the character's unit name and keep the base-unit fallback for NPCs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cast obstacle check still used the C# ray: +1 m at both ends, static+terrain (0x101), the default 0x8F flags and no radius gate. That rejects casts through obstacles the 1.2 client ignores and misses the client's target-surface shortening.
check_terrain), ray flags 0x2048F (collision class 2, ignore back faces, pierceability 15) and one hit; a hit maps to 0xC (skill_obstacle) (x2game.dll.c:149877FUN_390B5540).dist <= radius(FUN_390B5650,x2game.dll.c:149951).FUN_390B5C60->FUN_3989C0D0,x2game.dll.c:150156and:1932675); position (ground) targets use the constant 0.5 (DAT_3999C47C) and skip only the source (FUN_390B5A30->FUN_390B5790,x2game.dll.c:150072,:149979,:150024and:150142).raycast_ignoring_objects: unit colliders live inWorldState::living, notobjects, so the ignore list could never skip the caster or target (systems/ai/collision/mod.rs:396). This is a correctness fix for every masked ray; it does not change the skill ray itself, whose mask (7) already excludes living entities.The decompile constants were checked directly against
D:/aa-re/client12/out-x2game/x2game.dll.cand the unpacked DLL: objtypes 7 / 0x107 atx2game.dll.c:149916-149919, flags 0x2048F at:149930, one hit at:149931, result 0xC at:149939, theradius*radius < dist2gate at:149965, the target-radius shortening at:149966-149969, the unit target radius at target+0x80 at:1932713-1932717, and the source+target skip inFUN_390B44D0(:390B44D0); the position path skips only the source (:150113-150123).DAT_3999C47Cis the float 0.5 (0x3F000000) in the unpacked DLL and is passed byFUN_390B5A30at:150142. The multi-part target variantFUN_3989DAE0(:1933912) is not modelled.Validation
nick/rust-rewrite(c6befb58c) with only the new test file:cargo test -p aaemu-game obstacle_ray -- --nocapture-> 0 passed, 2 failed.obstacle_ray_matches_the_retail_height_mask_and_collision_classfailed atcast_validation_tests.rs:1011(the old +1 m ray hit a wall above the feet);obstacle_ray_skips_inside_radius_and_uses_the_position_radiusfailed at:1191(a thin obstacle inside the target radius still blocked).fix/line-of-sight-1.2(b6d08357b): the same command -> 2 passed, 0 failed.cargo test -p aaemu-game cast_validation_tests-> 28 passed, 0 failed.cargo test -p aaemu-game unit_colliders_are_skippable_by_obj_id-> 1 passed, 0 failed. The test hits the living proxy without the ignore entry and passes through it with(ObjKind::Unit, 7); without thelivinglookup the ignore list is empty and it fails.cargo clippy -p aaemu-game --all-targets -- -D warnings-> passed.cargo xtask cionb6d08357bfromrust/(default test threads): game library 2,881 passed, 0 failed, 149 ignored (8.35 s), exit 0; testclient 57 library + 16 binary; formatting and Clippy clean; coverage ratchet 517 S->C opcodes, 105 without a Rust type, 65 typed but never sent, and 7 Python tests passed. One earlier default-thread run on the previous HEAD hit the timing-sensitivesystems::services::shutdown::tests::a_lobby_connection_appearing_during_the_shutdown_gets_the_world_list(NonevsSome(false)); it passes standalone, and the final default-thread run above is clean.Live: a local server stack (
liveprofile, its own databases) was built and started, and a headless GM testclient cast skill 2 in Arach Hollow. The fixed server logged the new feet-height rejection through a doodad (that run predates the name fix, socharacter=was empty):WARN validation - Skill line of sight blocked character= skill=2 target=17694 result_key="skill_obstacle" ... hit=Hit { ... owner: Some(Object { kind: Doodad, obj_id: 58380 }) }. A controlled before/after cast across a chosen obstacle edge was not reproduced headlessly: runtime-spawned templates 14201/5570/13451 did not appear in the client's unit list, 3492 spawned at an adjusted position and moved, skill 2's Hostile target type returnsNO_TARGETfor friendly NPCs, andcastmoves the caster to 1 m so a pre-placed wall moved with the NPC. The flow tests above are the rule's evidence. The live stack was stopped; no original client was started.Limits
Inferred, not read in the decompile: the client shows only the actor-target path, so doodad, house and slave targets use the same unit semantics here (with radius 0 for doodads); the original's skip of the caster's own vehicle/ship collider is not modelled, so a caster standing on a ship may still be blocked by its hull as before; multi-part targets (
FUN_3989DAE0) are not modelled.The unit target radius is
model_radius(model_id) * scale; the 1.2 value is target+0x80. Their equality is not proven (the tests inject a radius).The multi-part target variant
FUN_3989DAE0(loops the target's sub-shapes and passes if any part passes) is not modelled; only the single-shape unit path is.The zero-length fallback direction in
FUN_390B5650(dist2 <= epsilon) is not modelled; Rust leaves the end point at the target, which has the same practical outcome.The server's collider world is not the client's render geometry; object type and collision class assignment remain data-dependent.
No controlled live obstacle-edge cast is claimed; only the deterministic flow tests and the observed live rejection above.
Review: an independent reviewer (R1) re-read
FUN_390B5650,FUN_390B5A30,FUN_390B5790and the unit path against the new constants, flags and radius gate, the gameplay risk (the new rule is more permissive than the C# ray) and the tests: qualified clear; its wording points are applied.🤖 Generated with Claude Code